<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script><script src="http://code.jquery.com/jquery-migrate-1.1.1.min.js"></script>
<script type="text/javascript">

</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
var trTag;
var totalBox;
var orderNo;
var t;
$(document).ready(function(){
	trTag = document.getElementById("tr1");
	totalBox = parseInt("${requestScope.totalBox }")/9;
	t = setInterval("aj()", 300);
	
	$("#releaseBtn").live("click", function(){
		orderNo = "${requestScope.oto.orderNo}";
		$.ajax({
			"url":"release.do",
			"type":"post",
			"data":{"method":"clickReleaseBtn",
					"orderNo":orderNo},
			"dataType":"json",
			"success":function(data){
				alert(data);
				if(data=="출고가 완료되었습니다."){
					$("#dState").empty();
					$("#dState").append("<b><font color='red'>true</font></b>");
				}
			},
			"error":function(xhr, status, errorMsg){
				alert("조회도중 오류 발생 : "+errorMsg);
			}
		});
	});
	
});
function aj(){
	$.ajax({
		"url":"release.do",
		"type":"post",
		"data":{"method":"continuouslyReferToData"},
		"dataType":"json",
		"success":function(data){
				for(var i=0; i<totalBox; i++){
					$("#a").empty();
					$("#a").attr("width", parseInt(100*(data/totalBox))*4).append(parseInt(100*(data/totalBox))+"%");
					$("#tid").empty().append(data+"BOX");
					if(data==totalBox){
						clearInterval(t);
					}
				}
				if(data==totalBox){
					$("#orderTb").after("<input type='button' id='releaseBtn' value='출고'>");
				}
		},
		"error":function(xhr, status, errorMsg){
			alert("조회도중 오류 발생 : "+errorMsg);
		}
	});
}
</script>
<style type="text/css">
.di{
	color: gray;
	font-size: large;
	border-style: ridge;
	border-color: aqua;
	border-width: 5pt;	
}
.tdc{
	color: black;
	font-weight: bold;
	height: 30pt;
	background-color: aqua;
}
</style>
</head>
<body>


총생산량 : ${requestScope.totalCnt}박스 
오늘의 주문
${requestScope.totalBox }



<form name="production">
<div class="di" style='height: 40%; width: 100%; float: none;'>
<b>완제품</b>
<table border="1" cellspacing="0">
	<tr>
		<td>수량</td>
	</tr>
	<tr>
		<td>${requestScope.totalCnt}박스 </td>
	</tr>
</table>
</div>
<div class="di" style="height: 50%; width: 45%; float: left;">
<b>오늘생산량</b>
<table border="1" cellspacing="0">
	<tr>
		<td>생산량</td>
	</tr>
	<tr>
		<td id="tid"></td>
	</tr>
</table>
<b>생산 현황</b>
<table>
	<tr id="tr1">
		<td id="a" class="tdc"></td>
	</tr>
</table>
</div>
<div class="di" style="height: 50%; width: 45%; float: right;">
<b>주문현황</b>
<table border="1" cellspacing="0" id="orderTb">
	<tr>
		<td>주문정보</td>
		<td>주문날짜</td>
		<td>주문처</td>
		<td>수량</td>
		<td>납품여부</td>
	</tr>
	<tr>
		<td>${requestScope.oto.orderNo}</td>
		<td>${requestScope.oto.orderDate}</td>
		<td>${requestScope.oto.orderer}</td>
		<td>${requestScope.totalBox }</td>
		<td id="dState">${requestScope.oto.deliveryState}</td>
	</tr>
</table>



</div>
</form>
</body>
</html>